package com.example.demo.service.sso;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户资源
 */
public class UserResource {
    private final int RESOURCE = 1;
    private final int MENU = 2;
    private final int PUBLIC = 3;

    private String id;
    private long applicationId;
    private String resourceName;
    private String resourceCode;
    private String url;
    private int resourceType;
    private String iconUrl;
    private String paramaters;
    private String describe;
    private List<UserResource> children;

    public UserResource copy(){
        UserResource userResource = new UserResource();
        userResource.id = id;
        userResource.applicationId = applicationId;
        userResource.resourceName = resourceName;
        userResource.resourceCode = resourceCode;
        userResource.url = url;
        userResource.resourceType = resourceType;
        userResource.iconUrl = iconUrl;
        userResource.paramaters = paramaters;
        userResource.describe = describe;
        userResource.children = children;
        return userResource;
    }

    /**
     * Gets the value of id.
     *
     * @return the value of id
     */
    public String getId() {
        return id;
    }

    /**
     * Sets the id.
     *
     * <p>You can use getId() to get the value of id</p>
     *
     * @param id id
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * Gets the value of applicationId.
     *
     * @return the value of applicationId
     */
    public long getApplicationId() {
        return applicationId;
    }

    /**
     * Sets the applicationId.
     *
     * <p>You can use getApplicationId() to get the value of applicationId</p>
     *
     * @param applicationId applicationId
     */
    public void setApplicationId(long applicationId) {
        this.applicationId = applicationId;
    }

    /**
     * Gets the value of resourceName.
     *
     * @return the value of resourceName
     */
    public String getResourceName() {
        return resourceName;
    }

    /**
     * Sets the resourceName.
     *
     * <p>You can use getResourceName() to get the value of resourceName</p>
     *
     * @param resourceName resourceName
     */
    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }

    /**
     * Gets the value of resourceCode.
     *
     * @return the value of resourceCode
     */
    public String getResourceCode() {
        return resourceCode;
    }

    /**
     * Sets the resourceCode.
     *
     * <p>You can use getResourceCode() to get the value of resourceCode</p>
     *
     * @param resourceCode resourceCode
     */
    public void setResourceCode(String resourceCode) {
        this.resourceCode = resourceCode;
    }

    /**
     * Gets the value of url.
     *
     * @return the value of url
     */
    public String getUrl() {
        return url;
    }

    /**
     * Sets the url.
     *
     * <p>You can use getUrl() to get the value of url</p>
     *
     * @param url url
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * Gets the value of resourceType.
     *
     * @return the value of resourceType
     */
    public int getResourceType() {
        return resourceType;
    }


    public boolean isResource(){
        return (this.resourceType & RESOURCE) == RESOURCE;
    }

    public boolean isMenu(){
        return (this.resourceType & MENU) == MENU;
    }

    public boolean isPublic(){
        return (this.resourceType & PUBLIC) == PUBLIC;
    }

    /**
     * Sets the resourceType.
     *
     * <p>You can use getResourceType() to get the value of resourceType</p>
     *
     * @param resourceType resourceType
     */
    public void setResourceType(int resourceType) {
        this.resourceType = resourceType;
    }

    /**
     * Gets the value of iconUrl.
     *
     * @return the value of iconUrl
     */
    public String getIconUrl() {
        return iconUrl;
    }

    /**
     * Sets the iconUrl.
     *
     * <p>You can use getIconUrl() to get the value of iconUrl</p>
     *
     * @param iconUrl iconUrl
     */
    public void setIconUrl(String iconUrl) {
        this.iconUrl = iconUrl;
    }

    /**
     * Gets the value of paramaters.
     *
     * @return the value of paramaters
     */
    public String getParamaters() {
        return paramaters;
    }

    /**
     * Sets the paramaters.
     *
     * <p>You can use getParamaters() to get the value of paramaters</p>
     *
     * @param paramaters paramaters
     */
    public void setParamaters(String paramaters) {
        this.paramaters = paramaters;
    }

    /**
     * Gets the value of describe.
     *
     * @return the value of describe
     */
    public String getDescribe() {
        return describe;
    }

    /**
     * Sets the describe.
     *
     * <p>You can use getDescribe() to get the value of describe</p>
     *
     * @param describe describe
     */
    public void setDescribe(String describe) {
        this.describe = describe;
    }

    /**
     * Gets the value of children.
     *
     * @return the value of children
     */
    public List<UserResource> getChildren() {
        return children;
    }

    /**
     * Sets the children.
     *
     * <p>You can use getChildren() to get the value of children</p>
     *
     * @param children children
     */
    public void setChildren(List<UserResource> children) {
        this.children = children;
    }



    public UserResource() {
        this.children = new ArrayList<>();
    }
}
